let str1 = 'aaaa'
const str2 = 'aaaa'

console.log(typeof str1);
console.log(typeof str2);


function changeDirection(direction: "up" | "down" | 'left' | 'right') {
  switch (direction) {
    case "up":
      console.log('向上移动');
      break;
    case "down":
      console.log('向下移动');
      break;
    case "left":
      console.log('向左移动');
      break;
    case "right":
      console.log('向右移动');
      break;
    default:
      console.log('无效方向');

  }
}
// changeDirection('aaa')
enum Direction {//默认值按照数组下标
  Up = 1,
  Down = 'aaa',
  Left = 4,
  Right
}
console.log(Direction.Right);

function getDirection(direction: Direction) {
  switch (direction) {
    case Direction.Up:
      console.log('向上移动');
      break;
    case Direction.Down:
      console.log('向下移动');
      break;
    case Direction.Left:
      console.log('向左移动');
      break;
    case Direction.Right:
      console.log('向右移动');
      break;
    default:
      console.log('无效方向');
  }
}
getDirection